<html>
<head>
<title>test_coos_extend_event</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
<script type="text/javascript" src="../coos.js"></script>
<script type="text/javascript">

//此函数会在页面加载后首先执行，并且只执行一次，类似于JUnit4中的@BeforeClass注解
function setUpPage()
{
	//此行代码必须放置在setUpPage的最后，在完成资源加载后告诉JsUnit该函数已执行完毕
	setUpPageStatus = "complete"; 
}


function setUp() //类比于JUnit中的setUp
{

}

function tearDown() //类比于JUnit中的tearDown
{

}

//test coos.hashmap
function testHashmap()
{
	var hs = coos.hashmap();
	hs.set("username","zhangsan");
	hs.set("username","lisi");
	var hs2 = coos.hashmap();
	hs2.set("username","zhangsan");
	hs2.set("username","lisi");
	var result = hs.get("username");
	assertEquals(hs2.get("username"),result);
}

//test coos.hashmap.getKeys
function testHashmapGetKeys()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.set("age","28");
	user.set("job","leader");
	var result = user.getKeys().toString();
	assertEquals(["name","age","job"].toString(),result);
}

//test coos.hashmap.getValues
function testHashmapGetValues()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.set("age","28");
	user.set("job","leader");
	var result = user.getValues().toString();
	assertEquals(["zhangsan","28","leader"].toString(),result);
}

//test coos.hashmap.remove
function testHashmapRemove()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.set("age","28");
	user.set("job","leader");
	user.remove("name");
	var result = user.getValues().toString();
	assertEquals(["28","leader"].toString(),result);
}

//test coos.hashmap.isEmpty
function testHashmapIsEmpty()
{
	var user = coos.hashmap();
	var result = user.isEmpty();
	assertEquals(true,result);
	user.set("name","zhangsan");
	var result = user.isEmpty();
	assertEquals(false,result);
}

//test coos.hashmap.clear
function testHashmapClear()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.clear();
	var result = user.get("name");
	assertEquals(null,result);
}

//test coos.hashmap.toString
function testHashmapToString()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.set("age","28");
	user.set("job","leader");
	var result = user.toString();
	assertEquals('{"name":"zhangsan","age":"28","job":"leader"}',result);
}

//test coos.hashmap.toJson
function testHashmapToJson()
{
	var user = coos.hashmap();
	user.set("name","zhangsan");
	user.set("age","28");
	user.set("job","leader");
	var result = user.toJson().toString();
	assertEquals({"name":"zhangsan","age":"28","job":"leader"}.toString(),result);
}
</script>
</head>
<body>
<div id="testEvent">testEvent</div>
</body>
</html>